/*
 * @Title: community
 * @Description: TODO
 * @author MI
 * @date 2022/7/22 10:15
 * @version
 */
package com.shanshan.community.mapper;

import com.shanshan.community.entity.LoginTicket;
import org.apache.ibatis.annotations.*;

/**
 * @author MI
 * @ClassName: LoginTicketMapper
 * @Description: TODO
 * @date 2022/7/22 10:15
 */
@Mapper
public interface LoginTicketMapper {

    //登录成功时插入一条凭证
    @Insert({"insert into login_ticket values (#{id},#{userId},#{ticket},#{status},#{expired})"})
    @Options(useGeneratedKeys = true,keyProperty = "id")
    int insertLoginTicket(LoginTicket loginTicket);

    //根据登录凭证查询loginTicket
    @Select({"select * from login_ticket where ticket=#{ticket}"})
    LoginTicket selectByTicket(String ticket);

    //更新状态
    @Update({"<script>update login_ticket set status=#{status} where ticket=#{ticket}  <if test=\"ticket!=null\"> and 1=1 </if></script>"})
    int updateStatus(String ticket, int status);
}
